package com.example.springboottest.student.controller;


import com.example.springboottest.student.entity.StudentEntity;
import com.example.springboottest.student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student2")
public class StudentController {

    @Autowired
    StudentService studentService;

    @RequestMapping("/getOne/{s_id}")
    public List<StudentEntity> getAll(@PathVariable("s_id") Integer s_id){
        return studentService.getOne(s_id);
    }

    @PostMapping("/save")
    @ResponseBody
    public String save(@RequestBody StudentEntity studentEntity){
        studentService.save(studentEntity);
        return "success";
    }
}

